import passport from 'passport';
import express from 'express';
const session = require('express-session');
const MySQLStore = require('express-mysql-session')(session);


export default function initPassportAndSessions(app: express.Application) {

app.use(session({
    secret: 'session_cookie_secret',
    resave: false,
    saveUninitialized: false,
    cookie: { maxAge: 1000*60*60*24},
    name: "sessionName",
    store: new MySQLStore({
        host: 'localhost',
        port: 306,
        user: 'session_test',
        password: 'password',
        database: 'session_test'
      })

}));

app.use(passport.initialize());
app.use(passport.session());

console.log("passport and sessions loaded")
}